Refactor/single process multiple services#785
Open
renatomaia wants to merge 14 commits into
Open
Conversation
renatomaia
force-pushed
the
refactor/SingleProcessMultipleServices
branch
3 times, most recently
from
June 26, 2026 13:53
758ef1a to
426dd48
Compare
renatomaia
marked this pull request as draft
July 8, 2026 18:08
… in 'Tick' functions
renatomaia
force-pushed
the
refactor/SingleProcessMultipleServices
branch
2 times, most recently
from
July 15, 2026 20:03
7902169 to
988508b
Compare
renatomaia
marked this pull request as ready for review
July 15, 2026 20:16
renatomaia
force-pushed
the
refactor/SingleProcessMultipleServices
branch
from
July 16, 2026 13:10
988508b to
40a197a
Compare
mpolitzer
previously approved these changes
Jul 16, 2026
There was a problem hiding this comment.
Pull request overview
This PR refactors the runtime from a “one service owns others” model into a single-process supervisor that creates and manages multiple services (tick-based and HTTP-based) under one lifecycle, driven primarily by context.Context cancellation and errors.Join error aggregation.
Changes:
- Introduces a
Supervisorruntime to create, start, stop, and tear down multiple services in one process (including OS signal handling and supervisor-owned/livez). - Adds reusable service templates:
TickServiceTemplate(polling + immediate retick via(bool, error)) andHTTPServiceTemplate(hardened HTTP server + middleware wiring + graceful shutdown). - Refactors core services (advancer, claimer, evmreader, prt, validator, inspect, jsonrpc) and CLIs to use the new templates/supervisor and to pass context explicitly into work functions.
Reviewed changes
Copilot reviewed 68 out of 68 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/validator/validator_test.go | Updates validator integration tests to new Create and Tick(ctx) APIs. |
| pkg/service/tick.go | Adds tick-based service template with reschedule-by-return-value semantics. |
| pkg/service/tick_test.go | Adds tests for TickServiceTemplate.Serve() behavior (cancellation, reschedule). |
| pkg/service/telemetry.go | Adds supervisor-owned telemetry HTTP service exposing /readyz and /livez. |
| pkg/service/telemetry_test.go | Updates telemetry tests for supervisor-managed telemetry service. |
| pkg/service/supervisor.go | Adds Supervisor orchestration (init/start/stop/teardown, signals, telemetry). |
| pkg/service/supervisor_test.go | Adds coverage for supervisor lifecycle, readiness, failure modes, stop semantics. |
| pkg/service/service_test.go | Replaces legacy service loop tests with a basic BaseTemplate invariant test. |
| pkg/service/http_service.go | Adds reusable hardened HTTP service template with graceful shutdown on ctx cancel. |
| internal/validator/validator.go | Refactors validator to TickServiceTemplate and Tick(ctx) (bool, error). |
| internal/validator/validator_test.go | Updates validator unit tests to new base template init. |
| internal/prt/validation_test.go | Updates PRT validation tests to avoid relying on service-owned context/cancel. |
| internal/prt/service.go | Refactors PRT to TickServiceTemplate, explicit context usage, internal eth client creation. |
| internal/prt/fixture_test.go | Updates PRT fixtures to use TickServiceTemplate embedding/init. |
| internal/node/node.go | Removes legacy node “parent service with children” implementation. |
| internal/manager/types.go | Removes Close() error from MachineProvider interface. |
| internal/manager/manager.go | Changes machine manager Close() to log errors instead of returning joined error. |
| internal/manager/manager_test.go | Updates tests to validate close failures via logs rather than returned error. |
| internal/jsonrpc/util_test.go | Updates JSON-RPC test helper to new Create signature and config pattern. |
| internal/jsonrpc/service.go | Refactors JSON-RPC into HTTPServiceTemplate-based supervised service. |
| internal/jsonrpc/service_test.go | Updates JSON-RPC tests to use HTTPServiceTemplate fields (Server, Admission). |
| internal/inspect/inspect.go | Refactors inspector into HTTPServiceTemplate-based supervised service. |
| internal/inspect/inspect_test.go | Updates inspect tests to initialize base template for logging/fields. |
| internal/evmreader/service.go | Refactors evmreader into TickServiceTemplate, supports injected eth client. |
| internal/evmreader/service_config_test.go | Updates evmreader config tests for new create/init and teardown behavior. |
| internal/evmreader/sealedepochs_test.go | Updates sealed epochs tests to init base template rather than legacy service create. |
| internal/evmreader/output_test.go | Updates output tests to call Serve(ctx) and new tick template init. |
| internal/evmreader/input_test.go | Updates input tests to call Serve(ctx) under new template. |
| internal/evmreader/input_scan_units_test.go | Updates scan unit tests to embed/init tick template logger. |
| internal/evmreader/foreclosure_test.go | Updates foreclosure fixture to init tick template instead of legacy service. |
| internal/evmreader/evmreader.go | Updates evmreader Tick(ctx) signature and context usage. |
| internal/evmreader/evmreader_test.go | Refactors tests to run evmreader under supervisor and updated readiness semantics. |
| internal/evmreader/edge_cases_test.go | Updates edge-case tests to stop supervisor instead of canceling service context. |
| internal/evmreader/accounts_drive_proved_test.go | Updates fixture to init tick template instead of legacy service create. |
| internal/cli/cobra.go | Suppresses logging for context.Canceled while preserving cobra.CheckErr. |
| internal/claimer/submit.go | Threads context through claim submission pipeline; joins errors instead of []error. |
| internal/claimer/stage.go | Threads context; returns joined error rather than slice; updates staging flow. |
| internal/claimer/stage_test.go | Updates staging tests for new signatures and context plumbing. |
| internal/claimer/service.go | Refactors claimer into TickServiceTemplate; creates eth client if not injected. |
| internal/claimer/service_test.go | Updates claimer create tests for new config-driven polling interval and type assertions. |
| internal/claimer/reverts.go | Threads context into revert classification/state mutation paths. |
| internal/claimer/reverts_test.go | Updates revert tests for new function signatures (ctx) and joined error semantics. |
| internal/claimer/inflight.go | Threads context through in-flight tx polling and state updates. |
| internal/claimer/inflight_test.go | Updates in-flight tests for new signatures and joined errors. |
| internal/claimer/foreclosure.go | Threads context; joins errors in foreclosure processing. |
| internal/claimer/foreclosed_apps_test.go | Updates tests for context-param foreclosure functions and joined error unwrapping. |
| internal/claimer/fixtures_test.go | Updates fixtures to init tick template instead of legacy service context fields. |
| internal/claimer/divergence.go | Threads context into divergence/error paths and DB mutations. |
| internal/claimer/divergence_test.go | Updates divergence tests to pass context and assert joined error behavior. |
| internal/claimer/claimer.go | Refactors main Tick pipeline to Tick(ctx) (bool, error) + reschedule by return value. |
| internal/claimer/claimer_test.go | Updates tick test to assert reschedule boolean instead of reschedule channel draining. |
| internal/claimer/claim_status.go | Threads context into claim status reconciliation DB updates. |
| internal/claimer/claim_status_test.go | Updates claim status tests for new ctx signatures. |
| internal/claimer/accept.go | Threads context through accept pipeline; joins errors instead of slices. |
| internal/advancer/service.go | Refactors advancer to tick template, uses supervisor for coordinated shutdown. |
| internal/advancer/advancer.go | Removes reliance on IsStopping; triggers global shutdown via supervisor on fatal errors. |
| internal/advancer/advancer_test.go | Updates advancer tests for new Tick(ctx) signature and supervisor stop semantics. |
| cmd/cartesi-rollups-validator/root/root.go | Switches validator binary to supervisor-managed startup/runtime. |
| cmd/cartesi-rollups-prt/root/root.go | Switches PRT binary to supervisor-managed startup/runtime. |
| cmd/cartesi-rollups-node/root/root.go | Replaces legacy node service with supervisor factories + shared machine manager. |
| cmd/cartesi-rollups-jsonrpc-api/root/root.go | Switches JSON-RPC binary to supervisor-managed startup/runtime. |
| cmd/cartesi-rollups-evm-reader/root/root.go | Switches evm-reader binary to supervisor-managed startup/runtime. |
| cmd/cartesi-rollups-claimer/root/root.go | Switches claimer binary to supervisor-managed startup/runtime. |
| cmd/cartesi-rollups-advancer/root/root.go | Switches advancer binary to supervisor-managed startup/runtime (and optional inspect). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
renatomaia
force-pushed
the
refactor/SingleProcessMultipleServices
branch
from
July 16, 2026 18:14
40a197a to
b144052
Compare
renatomaia
force-pushed
the
refactor/SingleProcessMultipleServices
branch
from
July 17, 2026 18:24
b144052 to
83fe452
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a new single-process service runtime:
Supervisorto create, run, stop, and tear down multiple services under one process.SIGINTandSIGTERMare handled by the supervisor and translated into graceful shutdown. UnusedSIGHUPreload support was removed.errorusingerrors.Join.Simplify the service lifecycle protocol:
context.Contextcancellation.service.stopping/IsStoppingstate and per-serviceStopsignaling were removed.Reloadwas removed because it was unused.Aliveis no longer implemented per service./livezis now supervisor-owned: it is true while the supervisor is serving and not stopping.Teardownwas added so services can release resources afterServeexits, although it is not currently being used.Add reusable service templates:
TickServiceTemplatefor tick-based services:HTTPServiceTemplatefor HTTP-backed services:Refactor supervised services:
Update tick and context APIs:
(bool, error)fromTick; the boolean controls whether another immediate tick should be scheduled.errorvalues instead of[]error.Behavior changes to note:
other service failures.